import request from '@/api/request'
import { AxiosPromise } from 'axios'

enum API {
    TREE_URL = "/system/menus/tree",
    ADD_URL = "/system/menus",
    UPDATE_URL = "/system/menus",
    DELETE_URL =  "/system/menus",
    BATCH_DELETE_URL = "/system/menus/batch-delete"
}

export const fetchMenusTreeApi = (query:any):AxiosPromise<any> => {
    return request.get<any>(API.TREE_URL,{params:query})
}

export const createMenuApi = (params:any):AxiosPromise<any> => {
    return request.post<any>(API.ADD_URL,params)
}

export const updateMenusApi = (params:any):AxiosPromise<any> => {
    return request.put<any>(API.UPDATE_URL,params)
}

export const deleteMenuByIdApi = (id:string):AxiosPromise<any> => {
    return request.delete<any>(API.DELETE_URL+'/'+id)
}

export const batchDeleteMenusApi = (ids:(string|number)[]):AxiosPromise<any> => {
    return request.put<any>(API.BATCH_DELETE_URL,ids)
}